/**
 * Order Book DTO
 */
class OrderBookDto {
  /**
   * constructor
   * @param {Array<Order>} buyOrderTop
   * @param {Array<Order>} sellOrderTop
   * @param {Integer} top
   */
  constructor({ buyOrderTop, sellOrderTop, top }) {
    this.top = top;
    this.buyOrderTop = this._buildOrderTop(buyOrderTop);
    this.sellOrderTop = this._buildOrderTop(sellOrderTop);
  }

  /**
   * build order book item
   * @param {Array<Order>} orderTop
   * @return {Array<OrderBook>}
   * @private
   */
  _buildOrderTop(orderTop) {
    const top = new Array();
    for (const order of orderTop) {
      top.push({ price: order.price, amount: Number(order.get('amount')) });
    }
    return top;
  }
}

module.exports = OrderBookDto;
